package gui;

import java.awt.Graphics;
import java.awt.Image;
import java.awt.image.ImageObserver;
import javax.swing.ImageIcon;
import javax.swing.JLabel;

@SuppressWarnings("serial")
public class JPanelWithBackground extends JLabel {
	private Image backgroundImage;
	private ImageObserver imageObserver;

	public JPanelWithBackground(String fileName) {

		ImageIcon icon = new ImageIcon(fileName);
		backgroundImage = icon.getImage();
		imageObserver = icon.getImageObserver();
	}

	public void paintComponent(Graphics g) {
		g.drawImage(backgroundImage, 0, 0, getWidth(), getHeight(),
				imageObserver);
		super.paintComponent(g);
	}
}